//
//  LimitsOfAuthorityViewController.m
//  PigMarket
//
//  Created by mac on 2019/7/5.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "LimitsOfAuthorityViewController.h"
#import "LookFriendListViewController.h"

@interface LimitsOfAuthorityViewController ()
/**
 bgview
 */
@property (nonatomic , strong) UIView *bgView;
/**
 tips
 */
@property (nonatomic , strong) YYLabel *tipsLab;
/**
 加号
 */
@property (nonatomic , strong) UIImageView *addIcon;
/**
 title
 */
@property (nonatomic , strong) UILabel *titleLab;
@end

@implementation LimitsOfAuthorityViewController


#pragma mark - view life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置权限";
    [self setUpView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

#pragma mark - init method
- (void)setUpView {
    [self initView];
    [self initLayout];
    [self initAction];
    [self initData];
}
- (void)initView {
    [self.view addSubview:self.tipsLab];
    [self.view addSubview:self.bgView];
    [self.view addSubview:self.addIcon];
    [self.view addSubview:self.titleLab];
}

- (void) initLayout {
    [self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(7);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(ScaleHeight(44));
    }];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.tipsLab.mas_bottom).offset(7);
        make.height.mas_equalTo(60);
    }];
    [self.addIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(30);
    }];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.addIcon.mas_right).offset(15);
        make.height.mas_equalTo(22);
        make.centerY.mas_equalTo(self.bgView.mas_centerY);
    }];
}

- (void) initAction {
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addLimitTap)];
    [self.bgView addGestureRecognizer:tap];
}

- (void)initData {
    
}

#pragma mark - delegate

#pragma mark - target action
- (void)addLimitTap {
    LookFriendListViewController *vc = [[LookFriendListViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - private method

#pragma mark - getter and setter
- (YYLabel *)tipsLab {
    if (!_tipsLab) {
        _tipsLab = [[YYLabel alloc] init];
        _tipsLab.numberOfLines = 0;
        NSString *tipsStr = @"温馨提示：开放摄像头权限后，一天可观看多次，一次最多观看5分钟，直到此猪出栏永久观看。";
        NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:tipsStr];
        text.yy_font = [UIFont systemFontOfSize:12];
        text.yy_color = [UIColor colorWithHexString:@"#969696"];
        text.yy_lineSpacing = 10;
        _tipsLab.attributedText = text;
    }
    return _tipsLab;
}
- (UIView *)bgView {
    if (!_bgView ) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}
- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.textColor = [UIColor colorWithHexString:@"#666666"];
        _titleLab.font = [UIFont systemFontOfSize:16];
        _titleLab.text = @"开放购买人观看权限";
    }
    return _titleLab;
}
- (UIImageView *)addIcon {
    if (!_addIcon) {
        _addIcon = [[UIImageView alloc] init];
        _addIcon.image = [UIImage imageNamed:@"adopted_look_add"];
    }
    return _addIcon;
}
@end
